<template>
  <div>
    <form>
      <label>姓名：</label>
      <input type="text" v-model="name"><br><br>

      <label>年龄：</label>
      <input type="number" v-model.number="age"><br><br>

      <label>身高：</label>
      <input type="number" v-model.number="height">(米)<br><br>

      <label>体重：</label>
      <input type="heighter" v-model.number="weight">(公斤)<br><br>

      <label>病史：</label>
      <input type="text" v-model="history"><br><br>

      <button @click.prevent="add()">诊断</button>
    </form>

    <p>患者{{ name }} 的诊断结果:{{ outcome }}</p>
    <p>{{ bmi }}</p>
  </div>
  
</template>

<script>
export default {
  data () {
    return {
      name:``,
      age:0,
      height:0,
      weight:0,
      history:``,
      outcome:``,
      bmi:0
    }
  },
  methods: {
    add(){
      this.bmi=this.weight/(this.height*this.height)
      if (this.bmi<18.5) {
        this.outcome=`体重过轻`
      }
      else if (this.bmi<=23.9) {
        this.outcome=`正常`
      }
      else if (this.bmi<=27) {
        this.outcome=`体重过重`
      }
      else if (this.bmi<=32) {
        this.outcome=`肥胖`
      }
      else if (this.bmi>32) {
        this.outcome=`非常肥胖`
      }
      console.log(this.outcome);
  }
    }
    
}
</script>
